package com.example.java_websocket.web.controller;

import com.example.java_websocket.service.IMessageRankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

@RestController
@RequestMapping("/messageRank")
@Api(tags = "聊天记载接口")
public class MessageRankController {

    @Autowired
    private IMessageRankService messageRankService;

    // 增加用户消息计数
    @PostMapping("/increment")
    @ApiOperation("用户消息计数接口")
    public String incrementMessageCount(@RequestParam String userId) {
        messageRankService.incrementMessageCount(userId);
        return "用户的消息计数 " + userId + " 已成功递增";
    }

    // 获取Top10用户
    @GetMapping("/top10")
    @ApiOperation("Top10用户接口")
    public Set getTopUsers() {
        return messageRankService.getTopUsers();
    }
}
